﻿using daonaite.Model.system.role_menu;
using daonaite.services.system;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace daonaite.api.Controllers.system
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class RoleMenuController : BaseController
    {
        private readonly role_menuService rmcz;

        public RoleMenuController(role_menuService rmcz)
        {
            this.rmcz = rmcz;
        }

        /// <summary>
        /// 根据角色查询菜单
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> getbyrole(int roleId)
        {
          var result = await  rmcz.getbyroleAsync(roleId);
            return Success(result);
        }

        /// <summary>
        /// 更新菜单信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> update_mensid(sys_role_menu data)
        {
           var result = await rmcz.update_mensidAsync(data);
            return Success(result);
        }
    }
}
